/**
 * 
 */
package cosc617_blackteam;

/**
 * @author Laura
 * finds the first comment represented by the string and 
 * approves it
 */
public class CmdApproveComment implements I_Command {

	private InfoAggregator infoagg;
	private String comment;
	/**
	 * @param infoagg the InformationAggregator to be used
	 * @param comment the string representation of the comment to be approved
	 */
	public CmdApproveComment(InfoAggregator infoagg, String comment){
		this.infoagg = infoagg;
		this.comment = comment;
	}
	/* (non-Javadoc)
	 * @see cosc617_blackteam.I_Command#execute()
	 */
	@Override
	public Object execute() {
		for(Comment c : infoagg.getComments())
			if(c.toString().equals(comment)){
					c.setApproved(true);
					return null;
			}
		return null;
	}

}
